local blaze = require "blaze"
local app = require "club.threecard.blackjack"

local M = app.ui.activity()

M.store_watchers = {
    apploading = {
        ["加载进度变更"] = function(self, store, state, args)
            self.progress_text.text = state.progress.desc
            self.progress_image.fillAmount = state.progress.value
        end
    }
}

function M:ctor()
    self.res = "club.threecard.blackjack/ui/apploading.b:AppLoadingUI"
end

function M:after_route_enter(to, from)
    self:super("after_route_enter", to, from)
    self:start_coroutine(function()
        self.app.store.apploading.set_progress({
            value = 0.33,
            desc = "剩余3秒"
        })
        self.app.coroutine.wait(1)
        self.app.store.apploading.set_progress({
            value = 0.66,
            desc = "剩余2秒"
        })
        self.app.coroutine.wait(1)
        self.app.store.apploading.set_progress({
            value = 1.00,
            desc = "剩余1秒"
        })
        self.app.coroutine.wait(1)
        self.app.router.go("/blackjack/entrance")
    end)
end

return M
